package com.web.service;

import com.web.entity.Product;
import com.web.entity.User;
import com.web.exception.BusinessException;
import com.web.mapper.ProductMapper;
import com.web.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserService
{
    @Autowired
    private UserMapper userMapper;
    public User login(String username,String secret)
    {
        User user = userMapper.queryUserByUsernameAndSecret(username, secret);
        if(user==null)
        {
            //用户名或者密码错误
            throw new BusinessException(100404,"用户名或者密码错误!");
        }
        return user;
    };

    public User login1(String username)
    {
        User user = userMapper.queryUserByUsername(username);
        if(user==null)
        {
            //用户名或者密码错误
            throw new BusinessException(100404,"用户名错误!");
        }
        return user;
    };
}
